//
//  ZyaFeedHeader.swift
//  SlaughterClient
//
//  Created by zwb on 2018/6/1.
//  Copyright © 2018年 zwb. All rights reserved.
//

import UIKit

class ZyaFeedHeader: UITableViewHeaderFooterView {
    
    lazy var label: UILabel = {
        let label = UILabel()
        label.text = ""
        label.numberOfLines = 0
        label.font = UIFont.boldSystemFont(ofSize: 17)
        return label
    }()
    
    var touchUpInside: ((Int) -> Void)?
    
    override init(reuseIdentifier: String?) {
        super.init(reuseIdentifier: reuseIdentifier)
        
        addSubview(label)
      
        label.frame = CGRect(x: 12, y: 0, width: ScreenWidth - 24, height: 44)
        
        let tapGesture = UITapGestureRecognizer(target: self, action: #selector(headerTouchUpInside(_:)))
        addGestureRecognizer(tapGesture)
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    @objc func headerTouchUpInside(_ gesture: UITapGestureRecognizer) {
        
        guard let tag = gesture.view?.tag else {
            return
        }
        
        if let actionClosure = touchUpInside {
            actionClosure(tag)
        }
    }
}

